﻿CREATE PROCEDURE [dbo].[yaf_accessmask_delete](
                @AccessMaskID INT)
AS
    BEGIN
        DECLARE  @flag INT
        SET @flag = 1
        IF EXISTS (SELECT 1
                   FROM   yaf_ForumAccess
                   WHERE  AccessMaskID = @AccessMaskID)
            OR EXISTS (SELECT 1
                       FROM   yaf_UserForum
                       WHERE  AccessMaskID = @AccessMaskID)
        SET @flag = 0
        ELSE
        DELETE FROM yaf_AccessMask
        WHERE       AccessMaskID = @AccessMaskID
        SELECT @flag
    END


